package com.cm.stock.manager.service;

import java.util.Date;
import java.util.List;

import com.cm.stock.manager.dao.FactureDAO;
import com.cm.stock.manager.dto.ClientDTO;
import com.cm.stock.manager.dto.FactureDTO;
import com.cm.stock.manager.dto.UserDTO;

public class FactureService {
	
	private FactureDAO factureDAO;
	
	public FactureDTO getFactureByCode(String code){
		return factureDAO.getByCode(code);
	}
	
	public FactureDTO saveFacture (double montantbrut, double montantnet, double solde, Date dateedition, Date datelivraison, Date daterendezvous, double remise, ClientDTO client, UserDTO user){
		String code = factureDAO.getMaxId()+"";
		return factureDAO.save(new FactureDTO(code, montantbrut, montantnet, solde, dateedition, datelivraison, daterendezvous, remise, client, user));
	}
	
	public FactureDTO updateFacture (FactureDTO facture){
		return factureDAO.update(facture);
	}
	
	public void deleteFacture (Integer id) throws Exception{
		factureDAO.deleteOne(id);
	}
	
	public List<FactureDTO> getFactureNonSolder(){
		return factureDAO.getAllNonSolder();
	}

	public void setFactureDAO(FactureDAO factureDAO) {
		this.factureDAO = factureDAO;
	}
	
	

}
